﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using OpenReflect.Domain.Contracts;

namespace OpenReflect.Domain.Model.CodeStructure
{
	public class CallExpression : Expression
	{
		public CallExpression(Expression source, IMethod method, IEnumerable<Expression> arguments)
			: this(source, method, new ReadOnlyCollection<Expression>(arguments.ToList()))

		{
		}

		public CallExpression(Expression source, IMethod method, ReadOnlyCollection<Expression> arguments)
			: base(ExpressionType.CallExpression)
		{
			Method = method;
			Arguments = arguments;
			Source = source;
		}

		public IMethod Method { get; private set; }
		public Expression Source { get; private set; }
		public ReadOnlyCollection<Expression> Arguments { get; private set; }
	}
}